﻿using System;
using System.Text;
using msilgc.cbuilder.CSyntaxTree;

namespace msilgc.CSyntaxTree {
    internal class AssignConstant : ICStatementWithAssignment {
        public IVariable Target { get; set; }
        public Object Constant { get; set; }
        public bool OnStack { get; set; }

        public AssignConstant(IVariable var, Object cst) {
            Target = var;
            Constant = cst;
            OnStack = true;
        }

        public void Emit(StringBuilder builder) {
            Target.Emit(builder);
            builder.Append(" = ");
            if(Constant is string)
            {
                builder.Append('\"');
            }
            builder.Append(Constant.ToString());
            if (Constant is string)
            {
                builder.Append('\"');
            }
            builder.AppendLine(";");
        }
    }
}
